import React, { useEffect, useRef } from 'react'
import Child from './Child'

export default function Index () {
  const inputRef = useRef(null)
  const childRef = useRef(null)

  useEffect(() => {
    // console.log(inputRef.current)
    inputRef.current.focus()
  }, [])

  const change = () => {
    console.log(childRef)
    childRef.current.setCount(9000)
  }
  return (
    <div>
      index
      <input type='text' ref={inputRef} />
      <br />
      <button onClick={change}>改子组件的值</button>
      <hr />
      <Child ref={childRef} />
    </div>
  )
}
